#include <stdio.h>
#include <limits.h>
/*int min(int a,int b){
    return a>b?b:a;
}
int max(int a,int b){
    return a>b?a:b;
}*/
#define min(a,b) ((a)>(b)?(b):(a))
#define max(a,b) ((a)>(b)?(a):(b))
int maxProfit(int* prices, int pricesSize) {
    int l=INT_MAX;
    int o=0;
    for( int sell_day=0; sell_day<pricesSize; sell_day++ ){
            o=max(o, prices[sell_day]-l);
            l=min(l, prices[sell_day]);
    }
    return o;
}

int main(){
    //int p[]={7,1,5,3,6,4};
    int p[]={7,6,4,3,1};
    printf("%d\n",maxProfit(p,sizeof(p)/sizeof(int)));
    return 0;
}
